package com.letao.server.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.letao.server.dto.Result;
import com.letao.server.entity.OrderStatusLog;
import com.letao.server.mapper.OrderStatusLogMapper;
import com.letao.server.service.IOrderStatusLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class OrderStatusLogServiceImpl extends ServiceImpl<OrderStatusLogMapper, OrderStatusLog> implements IOrderStatusLogService {

    /**
     * 查询订单流水明细
     *
     * @param orderId 订单的Id
     * @return 返回的结果
     */
    @Override
    public Result getListInfo(Long orderId) {
        List<OrderStatusLog> list = query().eq("order_id", orderId).list();
        return Result.success(list);
    }

    @Override
    public void updateState(Long orderId, Integer state) {
        OrderStatusLog orderStatusLog = new OrderStatusLog();
        orderStatusLog.setOrderId(orderId);
        orderStatusLog.setOrderStatus(state);
        save(orderStatusLog);
    }
}
